var obj = $('#example23');
var url = obj.data('url');
obj.DataTable({
    dom: 'Bfrtip',
    buttons: [
        'copy', 'csv', 'excel', 'pdf', 'print'
    ],
    "ordering": true,
    "processing": true,
    "responsive": false,
    "lengthMenu": [
        [10, 20, 50, 100],
        ['10 行', '20 行', '50 行', '100 行']
    ],
    "order": [[0, "desc"]],
    // "columnDefs": [{
    //     orderable: false,
    //     targets: [1,2]
    // }],
    "language": {
        "sProcessing": '<div id="fountainG"><div id="fountainG_1" class="fountainG"></div><div id="fountainG_2" class="fountainG"></div><div id="fountainG_3" class="fountainG"></div><div id="fountainG_4" class="fountainG"></div><div id="fountainG_5" class="fountainG"></div><div id="fountainG_6" class="fountainG"></div><div id="fountainG_7" class="fountainG"></div><div id="fountainG_8" class="fountainG"></div></div>',
        "sLengthMenu": "显示 _MENU_ 项结果",
        "sZeroRecords": "没有匹配结果",
        "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
        "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
        "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
        "sInfoPostFix": "",
        "sSearch": "搜索:",
        "sUrl": "",
        "sEmptyTable": "暂无记录",
        "sLoadingRecords": "载入中...",
        "sInfoThousands": ",",
        "oPaginate": {
            "sFirst": "首页",
            "sPrevious": "上一页",
            "sNext": "下一页",
            "sLast": "末页"
        }
    },
    serverSide: true,
    ajax: {
        url: url,
        type: 'POST',
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    },
    "deferRender": true
});
$('.column_filter').on('change', function () {
    obj.DataTable().column($(this).data('column')).search($(this).val(), false, true).draw();
});
//跳转页
obj.append("  到第 <input type='text' id='changePage' class='input-text' style='width:50px;height:27px'> 页 ");
var oTable = obj.dataTable();
$('#changePage').keyup(function (e) {
    if ($(this).val() && $(this).val() > 0) {
        var redirectpage = $(this).val() - 1;
    } else {
        redirectpage = 0;
    }
    oTable.fnPageChange(redirectpage);
});


$(document).ready(function () {
    $('#summernote').summernote();
});
$('#summernote').summernote({
    height: 500,
    toolbar: [
        // [groupName, [list of button]]
        ['style', ['bold', 'italic', 'underline', 'clear']],
        ['fontsize', ['fontsize']],
        ['fontname', ['fontname']],
        ['color', ['color']],
        ['para', ['ul', 'ol', 'paragraph']],
        ['height', ['height']],
        ['insert', ['link', 'picture', 'video']],
        ['view', ['fullscreen', 'codeview', 'help']]
    ],
    lang: 'zh-CN',
    placeholder: '内容',
    dialogsFade: true,
    callbacks: {
        onImageUpload: function (files) {
            var data = new FormData();
            data.append("file", files[0]);
            $.ajax({
                data: data,
                type: "POST",
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                url: "/upload", /*填写后台上传文件的路径*/
                cache: false,
                contentType: false,
                processData: false,
                success: function (url) {/*url为上传成功后返回的图片路径*/
                    var imgNode = document.createElement('img');
                    imgNode.src = url;
                    $('#summernote').summernote('insertNode', imgNode);
                }
            })
        }
    }
});


$(document).ready(function () {
    $('#summernote1').summernote();
});
$('#summernote1').summernote({
    height: 500,
    toolbar: [
        // [groupName, [list of button]]
        ['style', ['bold', 'italic', 'underline', 'clear']],
        ['fontsize', ['fontsize']],
        ['fontname', ['fontname']],
        ['color', ['color']],
        ['para', ['ul', 'ol', 'paragraph']],
        ['height', ['height']],
        ['insert', ['link', 'picture', 'video']],
        ['view', ['fullscreen', 'codeview', 'help']]
    ],
    lang: 'zh-CN',
    placeholder: '内容',
    dialogsFade: true,
    callbacks: {
        onImageUpload: function (files) {
            var data = new FormData();
            data.append("file", files[0]);
            $.ajax({
                data: data,
                type: "POST",
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                url: "/upload", /*填写后台上传文件的路径*/
                cache: false,
                contentType: false,
                processData: false,
                success: function (url) {/*url为上传成功后返回的图片路径*/
                    var imgNode = document.createElement('img');
                    imgNode.src = url;
                    $('#summernote1').summernote('insertNode', imgNode);
                }
            })
        }
    }
});


// js 获取字符串中最后一个斜杠前面的内容
function geturlid() {
    var htmlHref = window.location.href;
    htmlHref = htmlHref.replace(/^http:\/\/[^/]+/, "");
    var addr = htmlHref.substr(htmlHref.lastIndexOf('/', htmlHref.lastIndexOf('/') - 1) + 1);
    var index = addr.lastIndexOf("\/");
    //js 获取字符串中最后一个斜杠后面的内容
    var addrLast = decodeURI(addr.substring(index + 1, addr.length));
    return addrLast;
}